package app.auto.designer.func;

import android.os.Bundle;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import app.auto.designer.R;
import app.auto.designer.ActivityBase;
import app.auto.runner.ActivityBaseCompact;
import app.auto.runner.base.MapViewConf;
import app.auto.runner.base.intf.ListBuilder;
import app.auto.runner.base.intf.MapBuilder;

public class FuncViewActivity extends ActivityBase {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_func);
        Map m = (Map) getIntent().getSerializableExtra("data");
        String desc = (String) m.get("desc");
        String type = (String) m.get("type");
        String[] types = type.split(";");
        getTextView(R.id.title).setText(desc);
        List<Map> listp = new ArrayList<Map>();
        MapViewConf listmvf = MapViewConf.with(getBaseContext()).source(R.layout.auto_param_layout).pair("pdesc->name");
        MapViewConf rootmvf = MapViewConf.with(getBaseContext()).source(new HashMap(),getView(R.id.basep)).conf(listmvf).toView();

        List<Map> listptype = new ArrayList<Map>();
        for (String s : types) {
            s = s.trim();
            String[] p = s.split(" ");
            String pdesc = p[0];
            if(p.length==1&&p[0].equals("")){
                break;
            }
            String p2 = p[1];
            String[] p3a = p2.split(":");
            String p3name = p3a[0];
            if (p3a.length > 1) {
                String p3type = p3a[1];
            } else {
                Map pmap = MapBuilder.build().add("paramname", p3name).add("pdesc", pdesc).get();
                listp.add(pmap);
                rootmvf.source(listp,getView(R.id.basep)).toView();

            }
        }

    }
}
